//
//  UIImage+MLKit.h
//  MLIM
//
//  Created by molon on 15/6/25.
//  Copyright (c) 2015年 molon. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIImage (MLKit)

/**
 *  圆角图像
 */
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius;
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius corners:(UIRectCorner)corners borderWidth:(CGFloat)borderWidth;


/**
 *  拍照获取从相册选取照片会翻转。这个方法来修正
 */
- (UIImage *)fixOrientation;

/**
 *  返回纯色图片
 */
+ (UIImage *)imageWithPureColor:(UIColor*)color;
+ (UIImage *)imageWithPureColor:(UIColor*)color withSize:(CGSize)size;

/**
 *  黑白系图
 */
- (UIImage *)grayImage;

/**
 *  下面三个可直接修改不透明色
 */
- (UIImage *)imageWithTintColor:(UIColor *)tintColor;
- (UIImage *)imageWithGradientTintColor:(UIColor *)tintColor;
- (UIImage *)imageWithTintColor:(UIColor *)tintColor blendMode:(CGBlendMode)blendMode;


/**
 *  水印
 */
- (UIImage*)imageWithTextWatermark:(NSString*)text andFont:(UIFont*)font andColor:(UIColor*)color andAngle:(CGFloat)angle andPoints:(NSArray*)points;


/**
 *  压缩图片直到某个大小，可能会改变图片的分辨率,压缩失败的话回调的compressedData是nil,maxSideLength是最大的边长，为0则忽略此参数
 */
- (void)dataFoCompressImageToMaxDataLength:(NSUInteger)maxDataLength maxSideLength:(CGFloat)maxSideLength withCallback:(void(^)(UIImage *originalImage,NSData *compressedData))callback;

/**
 *  修改图片的分辨率，让其中一个短边长为minSideLength
 */
- (UIImage*)imageByScalingToMinSideLength:(CGFloat)minSideLength;

/**
 *  各种裁剪
 */
- (UIImage*)imageByScalingToSize:(CGSize)newSize contentMode:(UIViewContentMode)contentMode;
- (UIImage*)imageByCroppingToBounds:(CGRect)bounds;
- (UIImage*)imageByScalingToFillSize:(CGSize)newSize;
- (UIImage*)imageByScalingAspectFillSize:(CGSize)newSize;
- (UIImage*)imageByScalingAspectFitSize:(CGSize)newSize;

/**
 *  mask处理
 */
- (UIImage*)maskImageWithMask:(UIImage *)maskImage;

@end
